package cn.lzd.service.impl;

import cn.lzd.bean.User;
import cn.lzd.dao.UserDao;
import cn.lzd.service.IUser;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by lzd on 2017/3/28.
 */
@Transactional
@Service("userImpl")
public class UserImpl implements IUser {


    @Autowired
    UserDao userDao;

    @Override
    public User test() {
        List<User> hello = userDao.findUser();
        System.out.println("拿到的对象个数 = " + hello.size());
        System.out.println("详情见 -->" + hello.get(0));

        return hello.get(0);
    }

    @Override
    public List<User> page() {
        PageHelper.startPage(2, 5);

        List<User> list = userDao.findUser();

        System.out.println(list.size());

        PageInfo<User> pageInfo = new PageInfo<>(list);

        System.out.println(pageInfo.getPageNum());

        return list;
    }
}
